package com.mapper;

import com.pojo.Students;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author lenove
 * @description 针对表【s_student】的数据库操作Mapper
 * @createDate 2024-11-15 11:16:37
 * @Entity com.pojo.Students
 */
public interface StudentsMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Students record);

    int insertSelective(Students record);

    Students selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Students record);

    int updateByPrimaryKey(Students record);

    @Select("select * from s_student where id = #{id}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "name", property = "name"),
            @Result(column = "age", property = "age"),
            @Result(column = "cla", property = "id",
                    one = @One(select = "com.mapper.CclassMapper.selectClassById"))})
    Students selectStudentById(int id);

    @Select("select * from s_student where cid = #{id}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "name", property = "name"),
            @Result(column = "age", property = "age"),
            @Result(column = "cla", property = "id")})
    List<Students> selectStudentsById(List id);

    @Update("update s_student set name = #{name} , age = #{age} where id = #{id}")
    int updateStudentById(Students students);
}
